﻿using MahApps.Metro.Controls;
using Prism.Regions;
using System.Windows;

namespace MetroApp.Web.Views
{
    /// <summary>
    /// Interaction logic for Login.xaml
    /// </summary>
    public partial class Login : MetroWindow
    {
        private readonly IRegionManager regionManager;

        public Login(IRegionManager regionManager)
        {
            InitializeComponent();
            this.regionManager = regionManager;

            this.txtUserName.Text = "admin";
            this.txtPassword.Text = "123456";
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //验证用户名和密码不为空
            if (this.txtUserName.Text == "" || this.txtPassword.Text == "")
            {
                MessageBox.Show("用户名或密码不能为空！");
                return;
            }

            //验证用户名和密码是否正确
            if (this.txtUserName.Text == "admin" && this.txtPassword.Text == "123456")
            {
                //跳转到主界面
                MainWindow mainWindow = new MainWindow(regionManager);
                mainWindow.Show();

                this.Close();
            }
            else
            {
                MessageBox.Show("用户名或密码错误！");
            }
        }
    }
}
